wayland: Add wayland-specific method to retrieve a device node path
authorCarlos Garnacho <carlosg@gnome.org>
Thu, 4 Aug 2016 16:59:09 +0000 (18:59 +0200)
committerCarlos Garnacho <carlosg@gnome.org>
Tue, 23 Aug 2016 19:01:44 +0000 (21:01 +0200)
This will be useful at least for g-c-c, in order to match libwacom
data with GdkDevices.

https://bugzilla.gnome.org/show_bug.cgi?id=770026

gdk/wayland/gdkdevice-wayland.c
gdk/wayland/gdkwaylanddevice.h

index 315ebdc39ad1d0757562dc92bb181f28f640e77a..1bdd924eb321c6e4d08aed8a8675bbcd15e8db4a 100644 (file)
@@ -4478,3 +4478,35 @@ gdk_wayland_device_get_drop_context (GdkDevice *device)
 
   return GDK_WAYLAND_SEAT (seat)->drop_context;
 }
+
+/**
+ * gdk_wayland_device_get_node_path:
+ * @device: a #GdkDevice
+ *
+ * Returns the /dev/input/event* path of this device.
+ * For #GdkDevices that possibly coalesce multiple hardware
+ * devices (eg. mouse, keyboard, touch,...), this function
+ * will return %NULL.
+ *
+ * This is most notably implemented for devices of type
+ * %GDK_SOURCE_PEN and %GDK_SOURCE_ERASER.
+ *
+ * Returns: the /dev/input/event* path of this device
+ **/
+const gchar *
+gdk_wayland_device_get_node_path (GdkDevice *device)
+{
+  GdkWaylandTabletData *tablet;
+
+  GdkSeat *seat;
+
+  g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
+
+  seat = gdk_device_get_seat (device);
+  tablet = gdk_wayland_device_manager_find_tablet (GDK_WAYLAND_SEAT (seat),
+                                                   device);
+  if (tablet)
+    return tablet->path;
+
+  return NULL;
+}
index a5b8ea00f1f3039fb033aa77dc9d5bc16445d2f0..b02ceeb8e8f62b46cb700b065552f42b699e15ab 100644 (file)
@@ -55,6 +55,8 @@ struct wl_keyboard  *gdk_wayland_device_get_wl_keyboard     (GdkDevice *device);
 GDK_AVAILABLE_IN_3_20
 struct wl_seat      *gdk_wayland_seat_get_wl_seat           (GdkSeat   *seat);
 
+GDK_AVAILABLE_IN_3_22
+const gchar         *gdk_wayland_device_get_node_path       (GdkDevice *device);
 
 G_END_DECLS